<?php

namespace AppBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use AppBundle\Task\AlertModelConfig;

class TradeReportCommand extends ContainerAwareCommand
{
    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this
            ->setName('app:trade:report')
            ->setDescription('okex futures trade symbol report.');
    }

    /**
     * 由CRONTAB 每分钟执行一次，获取最新正在交易的币，更新本地列表.
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $task = 'app.task.alert_model2.4';
        $job = $this->getContainer()->get($task);

        $output->writeln($job->version());
        $name = explode('-', $job->prefix())[0];
        $output->writeln($name);

        $type = AlertModelConfig::tradeTypeName($name,'test');

        $output->writeln($type);
        return;

        $uri = 'http://api.bidao.mmdata.cn/huobi_api/trademsg/report';
        /*
                {
                    data: [
                {
                    msg_version: "2.4",			// 消息版本号
                    symbol: "xrp_usd",		// 交易对
                    contract_type: "next_week",	// 合约类型
                    amount: 1,		// 持仓数量
                    type: "long"	// 做多
                },
                {
                    msg_version: "2.4",
                    symbol: "xrp_usd",
                    contract_type: "next_week",
                    amount: 2,
                    type: "short"	// 做空
                }],
                status: "success"
                }
        */
        $content = [];
        if ($content['status'] != 'success') {
            return;
        }

        $data = $content['data'];
        foreach ($data as $msg) {

        }
    }
}
